package org.example.petadoption.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.petadoption.entity.MerchantInfoDTO;
import org.example.petadoption.entity.User;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author PetAdoption
 * @since 2025-10-20
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("""
    SELECT 
        u.avatar AS avatar,
        m.name AS merchantName,
        m.category AS category,
        m.contact_person AS contactPerson,
        m.contact_phone AS contactPhone,
        m.created_at AS joinTime
    FROM merchant m
    LEFT JOIN user u ON m.user_id = u.id
    WHERE u.id = #{id}
""")
    MerchantInfoDTO selectMerchantInfoByUserId(@Param("id") int id);


}
